//
//  TLSearchBarView.m
//  Coding_iOS
//
//  Created by taolei-mac on 2017/12/29.
//  Copyright © 2017年 com.lianchuan. All rights reserved.
//

#import "TLSearchBarView.h"
#import "TLSearchBar.h"

@interface TLSearchBarView ()<UITextFieldDelegate>

@property (nonatomic, weak) TLSearchBar *searchBar;

@end

@implementation TLSearchBarView

- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame]){
        
        TLSearchBar *searchBar = [[TLSearchBar alloc] init];
        searchBar.placeholderStr = @"搜索";
        searchBar.delegate = self;
        searchBar.frame = CGRectMake(10.0, 7.5, TLScreenW - 20, 30);
        [self addSubview:searchBar];
        self.searchBar = searchBar;
        
        [searchBar.scanBtn addTarget:self action:@selector(scanButtonClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}

- (void)scanButtonClick
{
    if(self.scanBlock){
        
        self.scanBlock();
    }
}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if(self.searchBlock){

        self.searchBlock();
    }
    
    return NO;
}

@end
